import 'package:cbec_app/generated/json/base/json_convert_content.dart';
import 'package:cbec_app/entity/home/content/group_goods_data_entity.dart';
import 'package:cbec_app/entity/home/content/content_data.dart';

GroupGoodsDataEntity $GroupGoodsDataEntityFromJson(Map<String, dynamic> json) {
  final GroupGoodsDataEntity groupGoodsDataEntity = GroupGoodsDataEntity();
  final int? pageMargin = jsonConvert.convert<int>(json['page_margin']);
  if (pageMargin != null) {
    groupGoodsDataEntity.pageMargin = pageMargin;
  }
  final String? sizeType = jsonConvert.convert<String>(json['size_type']);
  if (sizeType != null) {
    groupGoodsDataEntity.sizeType = sizeType;
  }
  final String? showOriginPrice = jsonConvert.convert<String>(json['show_origin_price']);
  if (showOriginPrice != null) {
    groupGoodsDataEntity.showOriginPrice = showOriginPrice;
  }
  final String? displayScale = jsonConvert.convert<String>(json['display_scale']);
  if (displayScale != null) {
    groupGoodsDataEntity.displayScale = displayScale;
  }
  final String? imageFillStyle = jsonConvert.convert<String>(json['image_fill_style']);
  if (imageFillStyle != null) {
    groupGoodsDataEntity.imageFillStyle = imageFillStyle;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    groupGoodsDataEntity.title = title;
  }
  final String? cornerMarkType = jsonConvert.convert<String>(json['corner_mark_type']);
  if (cornerMarkType != null) {
    groupGoodsDataEntity.cornerMarkType = cornerMarkType;
  }
  final String? borderRadiusType = jsonConvert.convert<String>(json['border_radius_type']);
  if (borderRadiusType != null) {
    groupGoodsDataEntity.borderRadiusType = borderRadiusType;
  }
  final String? textAlignType = jsonConvert.convert<String>(json['text_align_type']);
  if (textAlignType != null) {
    groupGoodsDataEntity.textAlignType = textAlignType;
  }
  final int? goodsMargin = jsonConvert.convert<int>(json['goods_margin']);
  if (goodsMargin != null) {
    groupGoodsDataEntity.goodsMargin = goodsMargin;
  }
  final String? showCornerMark = jsonConvert.convert<String>(json['show_corner_mark']);
  if (showCornerMark != null) {
    groupGoodsDataEntity.showCornerMark = showCornerMark;
  }
  final String? uuid = jsonConvert.convert<String>(json['uuid']);
  if (uuid != null) {
    groupGoodsDataEntity.uuid = uuid;
  }
  final String? showSoldNum = jsonConvert.convert<String>(json['show_sold_num']);
  if (showSoldNum != null) {
    groupGoodsDataEntity.showSoldNum = showSoldNum;
  }
  final String? size = jsonConvert.convert<String>(json['size']);
  if (size != null) {
    groupGoodsDataEntity.size = size;
  }
  final String? navStyle = jsonConvert.convert<String>(json['nav_style']);
  if (navStyle != null) {
    groupGoodsDataEntity.navStyle = navStyle;
  }
  final String? textStyleType = jsonConvert.convert<String>(json['text_style_type']);
  if (textStyleType != null) {
    groupGoodsDataEntity.textStyleType = textStyleType;
  }
  final String? price = jsonConvert.convert<String>(json['price']);
  if (price != null) {
    groupGoodsDataEntity.price = price;
  }
  final String? sticky = jsonConvert.convert<String>(json['sticky']);
  if (sticky != null) {
    groupGoodsDataEntity.sticky = sticky;
  }
  final String? showSubTitle = jsonConvert.convert<String>(json['show_sub_title']);
  if (showSubTitle != null) {
    groupGoodsDataEntity.showSubTitle = showSubTitle;
  }
  final List<GroupGoodsDataSubEntry>? subEntry = (json['sub_entry'] as List<dynamic>?)?.map((e) => jsonConvert.convert<GroupGoodsDataSubEntry>(e) as GroupGoodsDataSubEntry).toList();
  if (subEntry != null) {
    groupGoodsDataEntity.subEntry = subEntry;
  }
  final String? cornerMarkImage = jsonConvert.convert<String>(json['corner_mark_image']);
  if (cornerMarkImage != null) {
    groupGoodsDataEntity.cornerMarkImage = cornerMarkImage;
  }
  final String? showAllGoodsTag = jsonConvert.convert<String>(json['show_all_goods_tag']);
  if (showAllGoodsTag != null) {
    groupGoodsDataEntity.showAllGoodsTag = showAllGoodsTag;
  }
  return groupGoodsDataEntity;
}

Map<String, dynamic> $GroupGoodsDataEntityToJson(GroupGoodsDataEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['page_margin'] = entity.pageMargin;
  data['size_type'] = entity.sizeType;
  data['show_origin_price'] = entity.showOriginPrice;
  data['display_scale'] = entity.displayScale;
  data['image_fill_style'] = entity.imageFillStyle;
  data['title'] = entity.title;
  data['corner_mark_type'] = entity.cornerMarkType;
  data['border_radius_type'] = entity.borderRadiusType;
  data['text_align_type'] = entity.textAlignType;
  data['goods_margin'] = entity.goodsMargin;
  data['show_corner_mark'] = entity.showCornerMark;
  data['uuid'] = entity.uuid;
  data['show_sold_num'] = entity.showSoldNum;
  data['size'] = entity.size;
  data['nav_style'] = entity.navStyle;
  data['text_style_type'] = entity.textStyleType;
  data['price'] = entity.price;
  data['sticky'] = entity.sticky;
  data['show_sub_title'] = entity.showSubTitle;
  data['sub_entry'] = entity.subEntry?.map((v) => v.toJson()).toList();
  data['corner_mark_image'] = entity.cornerMarkImage;
  data['show_all_goods_tag'] = entity.showAllGoodsTag;
  return data;
}

extension GroupGoodsDataEntityExtension on GroupGoodsDataEntity {
  GroupGoodsDataEntity copyWith({
    int? pageMargin,
    String? sizeType,
    String? showOriginPrice,
    String? displayScale,
    String? imageFillStyle,
    String? title,
    String? cornerMarkType,
    String? borderRadiusType,
    String? textAlignType,
    int? goodsMargin,
    String? showCornerMark,
    String? uuid,
    String? showSoldNum,
    String? size,
    String? navStyle,
    String? textStyleType,
    String? price,
    String? sticky,
    String? showSubTitle,
    List<GroupGoodsDataSubEntry>? subEntry,
    String? cornerMarkImage,
    String? showAllGoodsTag,
  }) {
    return GroupGoodsDataEntity()
      ..pageMargin = pageMargin ?? this.pageMargin
      ..sizeType = sizeType ?? this.sizeType
      ..showOriginPrice = showOriginPrice ?? this.showOriginPrice
      ..displayScale = displayScale ?? this.displayScale
      ..imageFillStyle = imageFillStyle ?? this.imageFillStyle
      ..title = title ?? this.title
      ..cornerMarkType = cornerMarkType ?? this.cornerMarkType
      ..borderRadiusType = borderRadiusType ?? this.borderRadiusType
      ..textAlignType = textAlignType ?? this.textAlignType
      ..goodsMargin = goodsMargin ?? this.goodsMargin
      ..showCornerMark = showCornerMark ?? this.showCornerMark
      ..uuid = uuid ?? this.uuid
      ..showSoldNum = showSoldNum ?? this.showSoldNum
      ..size = size ?? this.size
      ..navStyle = navStyle ?? this.navStyle
      ..textStyleType = textStyleType ?? this.textStyleType
      ..price = price ?? this.price
      ..sticky = sticky ?? this.sticky
      ..showSubTitle = showSubTitle ?? this.showSubTitle
      ..subEntry = subEntry ?? this.subEntry
      ..cornerMarkImage = cornerMarkImage ?? this.cornerMarkImage
      ..showAllGoodsTag = showAllGoodsTag ?? this.showAllGoodsTag;
  }
}

GroupGoodsDataSubEntry $GroupGoodsDataSubEntryFromJson(Map<String, dynamic> json) {
  final GroupGoodsDataSubEntry groupGoodsDataSubEntry = GroupGoodsDataSubEntry();
  final bool? isShowAll = jsonConvert.convert<bool>(json['isShowAll']);
  if (isShowAll != null) {
    groupGoodsDataSubEntry.isShowAll = isShowAll;
  }
  final int? goodsNumber = jsonConvert.convert<int>(json['goods_number']);
  if (goodsNumber != null) {
    groupGoodsDataSubEntry.goodsNumber = goodsNumber;
  }
  final String? createTime = jsonConvert.convert<String>(json['createTime']);
  if (createTime != null) {
    groupGoodsDataSubEntry.createTime = createTime;
  }
  final String? tagName = jsonConvert.convert<String>(json['tag_name']);
  if (tagName != null) {
    groupGoodsDataSubEntry.tagName = tagName;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    groupGoodsDataSubEntry.name = name;
  }
  final int? channelNum = jsonConvert.convert<int>(json['channelNum']);
  if (channelNum != null) {
    groupGoodsDataSubEntry.channelNum = channelNum;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    groupGoodsDataSubEntry.id = id;
  }
  return groupGoodsDataSubEntry;
}

Map<String, dynamic> $GroupGoodsDataSubEntryToJson(GroupGoodsDataSubEntry entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['isShowAll'] = entity.isShowAll;
  data['goods_number'] = entity.goodsNumber;
  data['createTime'] = entity.createTime;
  data['tag_name'] = entity.tagName;
  data['name'] = entity.name;
  data['channelNum'] = entity.channelNum;
  data['id'] = entity.id;
  return data;
}

extension GroupGoodsDataSubEntryExtension on GroupGoodsDataSubEntry {
  GroupGoodsDataSubEntry copyWith({
    bool? isShowAll,
    int? goodsNumber,
    String? createTime,
    String? tagName,
    String? name,
    int? channelNum,
    String? id,
  }) {
    return GroupGoodsDataSubEntry()
      ..isShowAll = isShowAll ?? this.isShowAll
      ..goodsNumber = goodsNumber ?? this.goodsNumber
      ..createTime = createTime ?? this.createTime
      ..tagName = tagName ?? this.tagName
      ..name = name ?? this.name
      ..channelNum = channelNum ?? this.channelNum
      ..id = id ?? this.id;
  }
}
